package dk.iha;

import android.content.Context;
import android.os.PowerManager;

public class AlarmAlertWakeLock {

    private static PowerManager.WakeLock sCpuWakeLock;
    private static Integer counterAcq = 0;
    private static Integer counterRel = 0;

    static void acquireCpuWakeLock(Context context) {

        counterAcq++;
        if (sCpuWakeLock != null) {
            return;
        }
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

        //SharedData.getInstance().addDebugDataLog_t("acquireCpuWakeLock");
        sCpuWakeLock = pm.newWakeLock(
                PowerManager.PARTIAL_WAKE_LOCK |
                PowerManager.ACQUIRE_CAUSES_WAKEUP,"okTag");
        sCpuWakeLock.acquire();
    }

    static void releaseCpuLock() {
        if (sCpuWakeLock != null) {
            sCpuWakeLock.release();
            sCpuWakeLock = null;
        }
        //SharedData.getInstance().addDebugDataLog_t("releaseCpuLock");
        counterRel++;
    }
}
